package com.samsung.sds.ssa.jsca.editor;
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;

import com.samsung.sds.ssa.jsca.Activator;

public class JSImages {
	@SuppressWarnings({"deprecation", "static-access"})
	public static final URL BASE_URL = Activator.getDefault().getDefault().getDescriptor().getInstallURL();
	public static final ImageDescriptor ICON_EDITOR;
	public static final ImageDescriptor ICON_VIEW_VARIABLE;
	public static final ImageDescriptor ICON_VIEW_FUNCTION;
	public static final ImageDescriptor ICON_VIEW_DYNAMIC_CLASS;
	public static final ImageDescriptor ICON_VIEW_CLASS;
	public static final ImageDescriptor ICON_VIEW_CLASS_METHOD;
	public static final ImageDescriptor ICON_VIEW_INSTANCE_METHOD;
	public static final ImageDescriptor ICON_VIEW_CLASS_VARIABLE;
	public static final ImageDescriptor ICON_VIEW_INSTANCE_VARIABLE;

	static {
		String iconPath = "icons/";

		ICON_EDITOR = createImageDescriptor(iconPath + "js.gif");
		ICON_VIEW_VARIABLE = createImageDescriptor(iconPath + "global_variable.gif");
		ICON_VIEW_FUNCTION = createImageDescriptor(iconPath + "func.gif");
		ICON_VIEW_CLASS = createImageDescriptor(iconPath + "class_obj.gif");
		ICON_VIEW_DYNAMIC_CLASS = createImageDescriptor(iconPath + "dyn_class_obj.gif");
		ICON_VIEW_CLASS_METHOD = createImageDescriptor(iconPath + "class_method.gif");
		ICON_VIEW_INSTANCE_METHOD = createImageDescriptor(iconPath + "instance_method.gif");
		ICON_VIEW_CLASS_VARIABLE = createImageDescriptor(iconPath + "class_variable.gif");
		ICON_VIEW_INSTANCE_VARIABLE = createImageDescriptor(iconPath + "instance_variable.gif");
	}

	private static ImageDescriptor createImageDescriptor(String path) {
		// URL url = new URL(BASE_URL, path);
		URL url = FileLocator.find(Platform.getBundle(Activator.PLUGIN_ID), new Path(path), null);

		return ImageDescriptor.createFromURL(url);

		// return ImageDescriptor.getMissingImageDescriptor();
	}
}
